package com.qzd.singleton.lazy;

/**
 * 懒汉式单例
 */
public class LazySimpleSingletion {

    private static LazySimpleSingletion instance;

    private LazySimpleSingletion() {
    }

    /**
     * 有线程安全问题（可能出现多个实例）
     *
     * @return
     */
    public static LazySimpleSingletion getInstance() {
        if (instance == null) {
            instance = new LazySimpleSingletion();
        }
        return instance;
    }

    /**
     * 加锁保证线程安全
     * 性能降低
     * @return
     */
    public synchronized static LazySimpleSingletion getInstance2(){
        if (instance == null) {
            instance = new LazySimpleSingletion();
        }
        return instance;
    }

}
